import com.darwinsys.util.Debug;
import java.io.*;

public class EnTab{

public static void main(String[] argv) throws IOException{
 	EnTab et = new EnTab(8);
 	if (argv.lenght == 0) 
  	et.entab(new BufferedReader(new InputStreamReader(System.in)));
  	else for(int i=0; i<argv.lenght; i++){
   		et.entab(new BufferedReader(new FileReader(argv[i])));
	}
 }

protected Tabs tabHandler;

public static int EOF = -1;


public EnTab(int n){
	tabHandler = new Tabs(n);
}


protected void putchar(int ch){
	System.out.print((char)ch);
}


public void entab(BufferedReader is)throws IOException{
	String line;
	int c, col = 0, newcol;


	do{
	 newcol = col;
	 
	 while((c = is.read()) == ' '){
		 Debug.println("Space", "Got space at " + col);
		  	newcol++;
	   	 if(tabHandler.tabpos(newcol)){
		   	Debug.println("tab", "Got a Tab Stop " + newcol);
		   	putchar('\t');
		   	col = newcol;
		}
	 }
	  
	 while(col < newcol){
	   Debug.println("pad", "Padding space at " + col);
	   putchar(' ');
	   col++;
	 }
	 Debug.println("out", "End of loop, c is " + c);

	 if (c != EOF){
	 	putchar(c);
		 col = (c == '\n' || c == '\r' ? 1 : col + 1);
	 }
	 }while (c != EOF);
	 	System.out.flush(); //returneaza tot pentru acest fisier.
	}
}
